package com.hinnotek.amoeba.viewmodels


import androidx.lifecycle.viewModelScope
import com.hinnotek.amoeba.base.BaseBean
import com.hinnotek.amoeba.bean.old.AmibaPayByAmibaPayIdBean
import com.hinnotek.amoeba.bean.old.RDProjectDetailBean
import com.hinnotek.amoeba.repo.ProjectRepo
import com.lee.common.base.BaseViewModel
import com.lee.common.network.net.StateLiveData
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.launch
import okhttp3.RequestBody
import javax.inject.Inject

@HiltViewModel
class ProjectViewModel  @Inject constructor(private val repository: ProjectRepo) :
    BaseViewModel() {

    private val baseBean = StateLiveData<BaseBean>()
    fun addCompanyProjectDistribution(body: RequestBody): StateLiveData<BaseBean> {
        viewModelScope.launch {
            repository.addCompanyProjectDistribution(body, baseBean)
        }
        return baseBean
    }


    fun addAmibaProject(body: RequestBody): StateLiveData<BaseBean> {
        viewModelScope.launch {
            repository.addAmibaProject(body, baseBean)
        }
        return baseBean
    }

    private val rDProjectDetailData = StateLiveData<RDProjectDetailBean>()

    fun getAmibaProjectById(amibaProjectId: Int): StateLiveData<RDProjectDetailBean> {
        viewModelScope.launch {
            repository.getAmibaProjectById(amibaProjectId, rDProjectDetailData)
        }
        return rDProjectDetailData
    }
}